package friends;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;


public class FirstReducer extends Reducer<Text,Text,Text,Text> {
    @Override
    protected void reduce(Text key, Iterable<Text> values, Context context) throws IOException, InterruptedException {
        //直接按规定格式写出（需拼接，）A:{B,C,D}
        StringBuilder sb = new StringBuilder();
       for(Text item:values){
           //values.iteator.hasNext()
           //B,C,D
           sb.append(item).append(",");
       }

        context.write(key,new Text(sb.toString()));//A:B,C,D
    }
}
